#include "napi/native_api.h"
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <initializer_list>
#include <forward_list>
#include <optional>
#include <bitset>
#include <variant>
#include <atomic>
#include <stack>
#include <unordered_map>
#include <unordered_set>

using namespace std;

void VarTest() {
    string sss = "qweqwe";
    std::vector<int> v = {1, 2, 3};
    std::map<int, int> intMap = {{1, 11}, {2, 22}};
    std::set<int> se = {3, 4, 5};
    std::multiset<int> mSet = {4, 4, 5};
    std::list<int> li = {7, 8, 9};
    std::stack<int> s;
    s.push(11);
    s.push(12);
    std::queue<int> q;
    q.push(11);
    q.push(12);
    std::deque<int> dq = {7, 8, 9};
    dq.push_back(13);
    dq.push_back(14);

    std::vector<int> vecArray[2] = {{1, 2, 3}, {4, 5, 6}};
    std::map<int, int> mapArray[2];
    mapArray[0].insert({1, 11});
    mapArray[0].insert({2, 22});
    mapArray[1].insert({3, 33});
    mapArray[1].insert({4, 44});
    std::forward_list<int> forwardList = {11, 22, 33};
    std::bitset<8> b(12);
    std::atomic<int> atomicInt(7);

    std::unordered_set<int> unSet = {3, 4, 5};
    std::unordered_map<int, int> unMap = {{1, 100}, {2, 200}};
    cout << sss << endl;
}
class Student
{
public:
    Student(char *name, int age, float score);
    void show();
private:
    char *m_name;
    int m_age;
    float m_score;
};

Student::Student(char *name, int age, float score){
    m_name = name;
    m_age = age;
    m_score = score;
}

void Student::show(){
    cout<<m_name<<"的年龄是"<<m_age<<",成绩是"<<m_score<<endl;
}
int test_class()
{
    Student stu((char*)"小明", 15, 92.5);
    stu.show();
    
    Student *pstu = new Student((char*)"李华", 16, 96);
    pstu->show();

    return 0;
}

double mix(double x,double y){
    return x*y;
}

void nullPtr()
{
    char* a[3] = {NULL};
    
    char tmp = 'c';
    
    char* b[2] = {&tmp, &tmp};
    
    int int_a = 2;
    
    int *aptr[2] = {};
    
    char* a_nullptr[3] = {nullptr};
    
    char* p = nullptr;
    
    char* p_null = NULL;
    
    int int_n[2] = {};
    int int_x[] = {1, 2};
    
    int int_y[2] = {1};
    
    cout<<int_a<<endl;
    
    if (p == nullptr){
        cout<<"p is nullptr"<<endl;
    }
    
    for (int i = 0; i < 2; i++)
    {
        cout<<int_y[i]<<endl;
    }
    
    for (int j = 0; j < sizeof(int_y)/sizeof(int); j++)
    {
        cout<<int_x[j]<<endl;
    }
    
    return;
}

void stringFunc()
{
    string str("test string");
    int length = str.length();
    
    cout<<"str is "<<str.c_str()<<endl;
    cout<<"length = "<<length<<endl;
    
    map<int, string> mapTemp;
    mapTemp.insert({5, "王老五"});
    mapTemp.insert({4, "李四"});
    mapTemp.insert({3, "张三"});
    
    map<int, string>::iterator it;
    for (it = mapTemp.begin(); it != mapTemp.end(); it++)
    {
        cout<<"学号："<<(*it).first<<" 姓名："<<(*it).second.c_str()<<endl;
    }
    
    return;
}

void double_test()
{
    double double_var=16.0;
    double double_max=32.0;

    double mul=mix(double_var,double_max);
    cout << mul << endl;
    
    return;
}

int main( )
{
    test_class();
    
    nullPtr();
    
    stringFunc();
    
    double_test();
    
    return 0;
}
